package com.xinrui.sunnyday.controller;

import com.xinrui.sunnyday.entity.Result;
import com.xinrui.sunnyday.exception.SunnydayException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class HealExceptionAdvice {
    /**
     * 自定义异常
     *
     * @param exception
     * @return
     */
    @ExceptionHandler(SunnydayException.class)
    public Result handleSunnydayException(SunnydayException exception) {
        return new Result(false, exception.getMessage());
    }

//    /**
//     * 其他未知异常
//     */
//    @ExceptionHandler(Exception.class)
//    public Result handleException(Exception e) {
//        return new Result(false, "发生未知异常，请联系管理员处理!");
//    }
}
